package struts.form;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

public class FullForm {
	public FullForm(){
		
	}
	
	public static ActionForm full(String formClass,HttpServletRequest request){
		ActionForm form = null;
		//利用类的反射
		try{
			Class clazz = Class.forName(formClass);
			form = (ActionForm) clazz.newInstance();
			Field[] filed_ar = clazz.getDeclaredFields();
			for(Field f :filed_ar ){
				f.setAccessible(true);
				f.set(form, request.getParameter(f.getName()));
				f.setAccessible(false);
			}
		}catch(Exception e){
			e.printStackTrace();
			System.out.println("form装载失败！");
		}
		return form;
	}

}
